package com.isolation.harassed.view;

import com.isolation.harassed.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

public class SplashActivity extends Activity {


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final View content = View.inflate(this, R.layout.activity_splash, null);
		setContentView(content);

		AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
		animation.setAnimationListener(new AppPreludeListener());
		animation.setDuration(3000);
		content.startAnimation(animation);

		initSystem();
	}

	/** 初始化系统 */
	private final void initSystem() {
		// empty handler
	}

	/**
	 * 注册网络无论成功失败都进入主页
	 * 
	 * @param registerNetwork
	 *            true or false
	 */
	private void goHomeActivity(boolean registerNetwork) {
		Intent goHome = new Intent(this, MainActivity.class);
		goHome.putExtra("NETWORK_STATE", registerNetwork);
		startActivity(goHome);
		finish();
	}

	/**
	 * 动画播放完毕即进入主页
	 * 
	 * @author allon
	 * @version 1.0.1
	 * @date 2016年3月6日
	 */
	private class AppPreludeListener implements AnimationListener {

		@Override
		public void onAnimationStart(Animation animation) {
		}

		@Override
		public void onAnimationEnd(Animation animation) {
			goHomeActivity(false);
		}

		@Override
		public void onAnimationRepeat(Animation animation) {
		}
	}
}
